package com.john.app.bmical;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class SuggestFragment extends Fragment {

	int mBmiResult;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		
        mBmiResult = getArguments().getInt(MainActivity.BMI_RESULT_FLAG);
        
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.suggest_view, container, false);
	}

	@Override
	public void onStart() {
		super.onStart();
		
        // Set state based on argument passed in
		updateSuggestContent(mBmiResult);
		
	}
	
	private void updateSuggestContent(int result) {
		TextView suggest = (TextView) getActivity().findViewById(R.id.tvSuggest);
		
		String suggestStr = getString(R.string.bmi_normal_suggest_content);
		if(mBmiResult == -1) {
			suggestStr = getString(R.string.bmi_high_suggest_content);
		} else if(mBmiResult == 1) {
			suggestStr = getString(R.string.bmi_low_suggest_content);
		}
		
		suggest.setText(String.format("这里是建议[%s]" , suggestStr));
	}

	@Override
	public void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		
	}
	
	
}
